clear all
use "Directed Dyad example file.dta", replace


*** Note: In the two following examples, the created spatial effect variable has no values for country_i=="Japan"
*** since Japan has no contiguous neighbor in this dataset

* Create specific source contagion spatial lag variable with (undirected) contiguity variable as connectivity variable
spspc  patentsfiled, weight(contig_or_less1000km) source(country_i) target(country_j) time(year) form(source) link(ik) sename(SL_spsource_W_contig) filename(SL_spsource_W_contig)

* As above, but not row-standardized
spspc  patentsfiled, weight(contig_or_less1000km) source(country_i) target(country_j) time(year) form(source) link(ik) sename(SL_spsource_W_contig_norowst) filename(SL_spsource_W_contig_norowst) norowst

* Create specific target contagion spatial lag variable with directed exports from j to m as connectivity variable (exports from i to j are automatically transformed)
spspc  patentsfiled, weight(exports_i_to_j) source(country_i) target(country_j) time(year) form(target) link(jm) sename(SL_sptarg_W_exports_i_to_j) filename(SL_sptarg_W_exports_i_to_j)


* Create specific target contagion spatial lag variable with directed exports from m to j as connectivity variable (exports from i to j are automatically transformed)
spspc  patentsfiled, weight(exports_i_to_j) source(country_i) target(country_j) time(year) form(target) link(mj) sename(SL_sptarg_W_exports_j_to_i) filename(SL_sptarg_W_exports_j_to_i) 
